<?php
	class namhocdb
	{
		public function Add($HocKy,$NamHoc)
		{
			$sql = "INSERT INTO `tbl_namhoc`(`HocKy`,`NamHoc`) VALUES (".dataservice::slashes($HocKy).",".dataservice::slashes($NamHoc).")";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Delete($NamHoc)
		{
			$sql = "DELETE FROM `tbl_namhoc` WHERE NamHoc = '$NamHoc' ";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
	
		public function GetList($HocKy, $NamHoc)
		{
			$sql = "SELECT * FROM `tbl_namhoc` WHERE 1";
			if($HocKy!="")
				$sql .= " AND HocKy = '$HocKy' ";
			if($NamHoc!="")
				$sql .= " AND NamHoc = '$NamHoc' ";
			$sql .= " ORDER BY  NamHoc DESC ";
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		public function GetListNamHoc($NamHoc)
		{
			$sql = " SELECT * FROM `tbl_namhoc` WHERE 1 ";
			if($NamHoc!="")
				$sql .= " AND NamHoc = '$NamHoc' ";
			$sql .= " GROUP BY	NamHoc ORDER BY  NamHoc DESC ";
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		
		public function Find($HocKy, $NamHoc)
		{
			$sql = "SELECT * FROM `tbl_namhoc` WHERE 1";
			if($HocKy!="")
				$sql .= " AND HocKy LIKE '%$HocKy%' ";
			if($NamHoc!="")
				$sql .= " AND NamHoc LIKE '%$NamHoc%' ";
			$sql .= " ORDER BY  NamHoc DESC ";
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		
	}
?>